<!DOCTYPE HTML>
<html lang="zh-cn">

	<head>
		<!--<base href="http://test.youxiduo.com/iweb/shixin_qiuqiu/" />-->
		<base href="http://resource.youxiduo.com/special/shihou/promoter/3399/">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width,user-scalable=no">
		<title>狮吼直播《球球大作战》零门槛主播培养计划</title>
		<meta name="keywords" content="狮吼,狮吼直播,手游直播,双投屏直播" />
		<meta name="description" content="狮吼 - 4亿手游玩家的直播平台、狮吼是游戏多旗下手游直播平台，支持双投屏直播的移动端平台，边玩边播，分享快乐！狮吼直播，随时随地录屏直播，语音弹幕独特玩法，各路主播游戏大神齐聚；电竞赛事、综艺娱乐、户外精彩，一切改变尽在 狮吼- 4亿手游玩家的直播平台。" />
		<link rel="stylesheet" href="static/css/base.css" />
		<link rel="stylesheet" href="static/css/style.css" />
		<script type="text/javascript" src="static/js/jquery-3.1.0.min.js"></script>
		<link rel="stylesheet" href="static/css/jquery-weui.css" />
		<script src="static/js/jquery-weui.js"></script>
		<script type="text/javascript" src="static/js/util.js"></script>
		<!--<script>
			var share_icon = "http://resource.youxiduo.com/special/shihou/promoter/46/static/img/wzry.png";
			var share_title = "王者荣耀玩家专属福利";
			var share_desc = "立领200元现金！分享再送30元，还不快来！";
			var plan_Id = "4PLwi6yLVak6";
			var share_conf_id = "3233";
			var signed = "1";
			var share_open = "1";
			var from_user_id = "1"; //244269
			var share_url = "http://m.shihou.tv/event_share/41?type=1&page=1&from_user_id=244272&share_config_id=41";
			var deviceId = "243";
		</script>-->
		<script language="JavaScript">
			//报名操作
			function signUp() {
				var url = util.baseUrl + "/ajax_sign_up";
				var data = {
					'from_user_id': from_user_id,
					"share_conf_id": share_conf_id,
					"deviceId": deviceId
				};
				util.log(data);
				$.ajax({
					url: url,
					type: 'GET',
					async: false,
					dataType: "jsonp",
					jsonp: "callback", //服务端用于接收callback调用的function名的参数(请使用callback或jsonp)
					jsonpCallback: "success_jsonpCallback", //callback的function名称
					data: data,
					success: function(data) {
						util.logResult(url, data);
						if(0 == data.errorCode) { //报名成功
							$('.pop').html("报名成功");
							$(".pop").fadeIn(200);
							setTimeout('$(".pop").hide()', 1500);
							//setTimeout('location.href=location.href', 1500);
							$("#signUp").attr("style", "display:none");
							$("#income").attr("style", "display:block");
						} else { //报名失败
							$(".pop").html(data.errorDescription);
							$(".pop").fadeIn(200);
							setTimeout('$(".pop").hide()', 3000);
						}
					}
				});
			}

			//获取用户信息
			function getUserInfo() {
				util.log('getUserInfo');
				$.ajax({
					url: util.baseUrl + '/UserInfoAjaxApiServlet',
					type: 'GET',
					async: false,
					dataType: "jsonp",
					jsonp: "callback", //服务端用于接收callback调用的function名的参数(请使用callback或jsonp)
					jsonpCallback: "success_jsonpCallback", //callback的function名称
					data: {
						'userId': from_user_id,
						"plantId": plan_Id,
						"activityId": share_conf_id
					},
					success: function(res) {
						util.logResult(util.baseUrl + '/UserInfoAjaxApiServlet', res);
						if(res.errorCode == '0') {
							var data = res.result;
							var kaiboTimeStr = data.kaiboTimeStr;
							var income = data.income;
							if(typeof(data.kaiboTimeStr) == "undefined" && kaiboTimeStr.length < 1)
								kaiboTimeStr = "无";
							if(typeof(data.income) == "undefined" && income.length < 1)
								income = "0";
							var baoming = '';
							if("1" == signed) { //已报名
								baoming = '<a id="signUp" href="javascript:void(0)" class="btnBm btnZj" onclick="signUp()" title="立即报名"><img src="static/img/btnBm.png" /></a>';
								baoming += '<a id="income" href="' + util.baseUrl + '/task/user_center?uid=' + from_user_id + '&plantId=' + plan_Id + '&activityId=' + share_conf_id + '" title="我的收益"><span class="btnOver btnZj" style="display:block;" title="我的收益"><img src="static/img/btnSy.png" /></span></a>';
							}else{//未报名
								baoming = '<a id="signUp" href="javascript:void(0)" class="btnBm btnZj" onclick="signUp()" title="立即报名"><img src="static/img/btnBm.png" /></a>';
								baoming += '<a id="income" style="display:none" href="' + util.baseUrl + '/task/user_center?uid=' + from_user_id + '&plantId=' + plan_Id + '&activityId=' + share_conf_id + '" title="我的收益"><span class="btnOver btnZj" style="display:block;" title="我的收益"><img src="static/img/btnSy.png" /></span></a>';
							}

							var html = '<div class="userInfo">' +
								'<span class="userHead"><img src="' + data.icon + '" /></span>' +
								'<span class="userName">' + data.nickName + '</span>' +
								'<span class="userTime">时长：<i>' + kaiboTimeStr + '</i></span>' +
								'<span class="userMoney">总收益：<i>' + income + '元</i></span>' +
								baoming +
								'</div>';
							$(".state").prepend(html);
						}
					},
					error: function(res) {
						console.log(JSON.stringify(res));
					}
				});

			}

			function success_jsonpCallback() {}

			//获取用户排名
			function getUserRank() {
				var url = util.baseUrlWage + '/UserRankAndExtra';
				var dateStr = $('#time').val().split(" ")[0];
				var data = {
					"activityId": share_conf_id,
					"userId": from_user_id,
					"startDate": dateStr,
					"endDate": dateStr
				};
				util.requestRemoteDataJson(url, data, function(res) {
					util.logResult(url, res);
					if(res.errorCode == "0") {
						var result = res.result;
						var rank = result.rank;
						var wage = result.shiya;
						var viewStatus = result.viewStatus;
						var viewTotal = result.viewTotal;

						if(parseInt(rank) > parseInt(viewTotal)) {
							rank = "0";
							wage = "0";
						}
						if(rank == "0")
							rank = "无";
						else
							rank += "名";
						if(wage == "0")
							wage = "无";
						else
							wage = (parseInt(wage) / 20) + "元"
						$('#rank').html(rank);
						$('#wage').html(wage);
						if(viewStatus == "1") {
							$('.nav').show();
						}
					}
				});
			}
		</script>
	</head>

	<body>

		<div class="wrap">
			<img src="static/img/mvpImage1.jpg" />
			<div class="main">
				<!--个人中心-->
				<div class="state">
					<div class="nav" style="display: none;">
						<p class="navSj g-auto">时间:
							<input class="weui_input" id="time" type="text" value="">
							<input type="text" value="" class="dispaly_value" />
							<span></span></p>
						<p class="navPm">排名:<i id="rank">无</i></p>
						<p class="navJl">奖励:<i id="wage">无</i></p>
					</div>
				</div>
				<!---未登录-->
				<div class="noLogin" style="display:none;">
					<img src="static/img/noLogin.png" />
				</div>
			</div>
			<div class="boxImg">
				<img src="static/img/mvpImage2.jpg" />
				<a class="share"><img src="static/img/share.png" /></a>
				<a href="http://m.shihou.tv/event_share/3233" class="pm"><img src="static/img/btnPm.png" /></a>
			</div>
			<img src="static/img/mvpImage3.jpg" />
			<img src="static/img/mvpImage4.jpg" />
			<img src="static/img/mvpImage5.jpg" />
			<img src="static/img/mvpImage6.jpg" />
			<img src="static/img/mvpImage7.jpg" />
			<img src="static/img/mvpImage8.jpg" />
			<img src="static/img/mvpImage9.jpg" />
			<img src="static/img/mvpImage10.jpg" />
			<img src="static/img/mvpImage11.jpg" />
			<img src="static/img/mvpImage12.jpg" />
		</div>
		<!-- 登录 -->
		<div class="pop">请登录后再来参加活动吧~</div>
	</body>

</html>
<script>
	var util;
	$(function() {
		util = new Util();
		var time = 3;
		$('.dispaly_value').val(util.getNowFormatDate(0, 0, -1));
		$("#time").val(util.getNowFormatDate(0, 0, -1) + " 00:00");
		//日历
		$("#time").datetimePicker({
			min: "2017-09-1 00:00",
			max: "2017-12-31 23:59",
		});

		$(".share").click(function() {
			if(from_user_id == "0") {
				$(".pop").fadeIn(200);
				setTimeout('$(".pop").hide()', time * 1000);
			} else {
				var web_share = {
					"qq": {
						"url": share_url,
						"img": share_icon,
						"title": share_title,
						"subtitle": share_desc
					},
					"wx_person": {
						"url": share_url,
						"img": share_icon,
						"title": share_title,
						"subtitle": share_desc
					},
					"wx_group": {
						"url": share_url,
						"img": share_icon,
						"title": share_title,
						"subtitle": share_desc
					},
					"wb": {
						"url": share_url,
						"img": share_icon,
						"title": share_title,
						"subtitle": share_desc
					}
				};

				if(typeof(window.lion) != "undefined" && typeof(window.lion.web_share) == 'function') {
					window.lion.web_share(JSON.stringify(web_share));
				}
			}
		});

		$('.loginBtn').click(function() {
			if(from_user_id == "0") {
				$(".pop").fadeIn(200);
				setTimeout('$(".pop").hide();window.location.href="shihoutv://route?jump_type=120";', time * 1000);
			}
		});

		$("#btn_sign").click(function() {
			if("1" == signed) {
				return;
			}
			if(from_user_id == "0") {
				$('.pop').html("请登录后，再点击分享");
				$(".pop").fadeIn(200);
				setTimeout('$(".pop").hide()', time * 1000);
			} else {
				signUp(); //报名操作
			}
		});

		if(from_user_id == 0 || from_user_id == '0') { //未登录
			$('.noLogin').show();
		} else { //已登录
			$('.noLogin').hide();
			getUserInfo();
			getUserRank();
		}

		//选择好时间后点击【确定】按钮
		$('.close-picker').on("click", function() {
			getUserRank();
		});
	});
</script>